package com.pmcc.core.vo;

import com.pmcc.core.entity.security.Region;
import lombok.Getter;
import lombok.Setter;

import java.util.List;

/**
 * Created by chuLiDong on 2018/5/27.
 */
@Getter
@Setter
public class RegionVo extends Region {
    private List<RegionVo> children;
    private String title;
    private String key;

    public String getTitle() {
        return title;
    }

    public void setTitle(String title) {
        this.title = title;
    }

    public String getKey() {
        return key;
    }

    public void setKey(String key) {
        this.key = key;
    }

    public List<RegionVo> getChildren() {
        return children;
    }

    public void setChildren(List<RegionVo> children) {
        this.children = children;
    }

    /**
     * Region -->VO
     *
     * @return
     */
    public static RegionVo getRegionVo(Region region){
        RegionVo regionVo=new RegionVo();
        if(region!=null){
            regionVo.setTitle(region.getFullName());
            regionVo.setKey(region.getId());
            regionVo.setId(region.getId());
            regionVo.setCode(region.getCode());
            regionVo.setName(region.getFullName());
            regionVo.setLevel(region.getLevel());
            regionVo.setParentId(region.getParentId());
        }
        return regionVo;
    }
}
